﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BangleCMS.Model;
using BangleCMS.BLL;
using System.Data;
using System.Linq;


public partial class MasterPage_Index : System.Web.UI.MasterPage
{
    public string PageCode
    {
        get
        {
            return Request.QueryString["t"] == null ? "" : Request.QueryString["t"];
        }
    }

    #region 属性
    private DataTable _link_list;
    /// <summary>
    /// 用于传数据台页面
    /// </summary>
    public DataTable DT_Link
    {
        get
        {
            return _link_list;
        }
        set
        {
            _link_list = value;
        }
    }

    private DataTable _dt_banner;

    public DataTable DT_Banner
    {
        get
        {
            return _dt_banner;
        }
        set
        {
            _dt_banner = value;
        }
    }

    private List<t_webnav> _nav_list;
    public List<t_webnav> nav_list
    {
        get { return _nav_list; }
        set { _nav_list = value; }
    }

    public List<t_webnav> NavListWhere(int ParentId)
    {
        return nav_list.Where(o => o.ParentId == ParentId).OrderBy(o => o.OrderNo).ToList();
    }

    public List<t_webnav> GetLeftWebnavList()
    {
        return nav_list.Where(o => o.Code == PageCode).OrderBy(o => o.OrderNo).ToList();
    }
    #endregion

    #region 加载
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GetDate();
        }
    }
    #endregion

    #region 获得数据
    private void GetDate()
    {
        UtilityBLL bll = new UtilityBLL();

        //数据绑定
        {
            DataSet ds = new DataSet();
            ds = bll.GetListByPage("t_link", "*", "Valid=1", "OrderNo,LinkId", 0, 1, 100);
            DT_Link = ds.Tables[0];
        }

        #region 绑定Banner数据
        DT_Banner = new UtilityBLL().GetListByPage("t_banner", "*", "Valid=1", "OrderNo", 0, 1, 10).Tables[0];
        #endregion

        #region 网站菜单
        t_webnavBLL nav_bll = new t_webnavBLL();
        nav_list = nav_bll.GetModelList("Valid=1").OrderBy(o => o.OrderNo).ToList();
        #endregion
    }
    #endregion

}
